package cn.com.victorysoft.wellinfo.service.impl;

import cn.com.victorysoft.wellinfo.domain.DailyProductionDataVO;
import cn.com.victorysoft.wellinfo.service.IDailyProductionDataService;
import cn.com.victorysoft.ylgl.service.commons.mybatis.MybatisRepository;
import cn.com.victorysoft.ylgl.service.commons.mybatis.paging.bean.DataPaging;
import cn.com.victorysoft.ylgl.service.commons.mybatis.paging.bean.PageRequest;
import cn.com.victorysoft.ylgl.service.commons.mybatis.paging.bean.Pageable;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * 单井生产信息
 * Created by Administrator on
 */

@org.springframework.stereotype.Component
public class DailyProductionDataService implements IDailyProductionDataService {

    private static final Logger logger = LoggerFactory.getLogger(DailyProductionDataService.class);
    @Resource
    private MybatisRepository mybatisRepository;

    @Override
    public DataPaging<DailyProductionDataVO> queryPagingList(String yt,
                                                             String qk,
                                                             String dk,
                                                             String cw,
                                                             String jh,
                                                             String startDate,
                                                             String endDate,
                                                             String rows,
                                                             String page) {
        Map<String, Object> params = new HashMap<>(7);
        params.put("yt", yt);
        params.put("qk", qk);
        params.put("dk", dk);
        params.put("cw", cw);
        params.put("jh", jh);
        params.put("startDate", startDate);
        params.put("endDate", endDate);
        int _page = 1;
        int _rows = Integer.MAX_VALUE;
        if (StringUtils.isNotBlank(page) && StringUtils.isNotBlank(rows)) {
            _page = Integer.parseInt(page);
            _rows = Integer.parseInt(rows);
        }

        PageRequest pageRequest = new PageRequest(_page, _rows, params  );
        DataPaging<DailyProductionDataVO> dataPaging = this.mybatisRepository.selectPaging(
                "cn.com.victorysoft.ylgl.webapp.service.wellBaseInfo.DrillingBaseMapper.selectPagingVO",
                (Pageable) pageRequest);
        return dataPaging;
    }
}